home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
quintus
/
quintus0.lha
/
work
/
main_2.06.2
< prev
next >
Wrap
Text File
|
1992-04-03
|
16KB
|
527 lines
%%% MAIN
%%% version 2.00.0 (based on main_19.4)
%%% added equality transformation
%%% version 2.00.1
%%% added equality rewriting
%%% version 2.00.3
%%% changed "equality_rewriting" to "auto_orient"
%%% added "outrwr", added "outrwt", added "outtreq", and "pullout_constants"
%%% version 2.00.5
%%% saved rewrite rules across sessions
%%% version 2.00.6
%%% added user specified rewrite rules and orderings
%%% version 2.00.8
%%% added lexicographic path ordering
%%% version 2.01.9
%%% optimized term rewriting
%%% version 2.03.4
%%% incorporated changes made to clin V1 between 7/31/90 and 10/18/90 which
%%% are visible externally -- changes to comments, predicate names, and
%%% variable names are not incorporated
%%% version 2.04.0
%%% logically erased nuclei while hyper-linking
%%% saved input clauses between sessions same as clin 1
%%% version 2.04.1
%%% determined maximum number of non-ground literals in a clause each round
%%% (required for equality transform)
%%% version 2.04.4
%%% when replacing and rewriting, perform replacement/rewrite repeatedly
%%% until no change
%%% version 2.04.5
%%% added restricted_rewrite to control whether restricted or unrestricted
%%% rewriting of equations is used
%%% added equality_transform_by_round flag
%%% added safe_early_priority_test flag
%%% added early_unit_subsumption flag
%%% added early tautology test
%%% added small_proof_nucleus_bound
%%% version 2.04.6
%%% added fixed_priority
%%% added start_priority_bound
%%% fixed bug in code which determines if another round of hyper-linking is
%%% required
%%% version 2.04.8
%%% added group_detection
%%% version 2.05.0
%%% don't select a support strategy unless there is a new clause or an
%%% existing clause has modified the appropriate support
%%% checked for duplicate partial instances
%%% version 2.05.1
%%% added clause splitting
%%% added gensym
%%% version 2.05.2
%%% modified the top level structure of clin
%%% version 2.05.3
%%% added support for Quintus Prolog
%%% version 2.05.4
%%% added banner to Quintus version
%%% fixed bug which prevented clause_splitting option from being printed
%%% version 2.05.5
%%% added equational rewriting
%%% version 2.05.6
%%% changed early unit subsumption to equality early unit subsumption
%%% added new early unit subsumption
%%% added print after clause generation
%%% version 2.05.8
%%% renamed assign/2 to assign_cmd/2 for compatibility with Quintus Prolog 3
%%% added priority_bound_increment
%%% version 2.06.0
%%% added clause_generation_loop flag
%%% added save_rewrite_rules
%%% version 2.06.1
%%% added constrained rewriting
%%% added save_unrestricted_normal_form
%%% version 2.06.2
%%% fixed duplicate setting of inifinity defaults
%%% added fast_priority_update
%%% added duplicate_partial_instance_test
%%% added precompute_constraints
%%% added restricted_equality_transform
%%% cached lexicographical path ordering
%%% added index and size bound to cached_rewrite
%%% added size bound to cached_constraint_consistent
%%% added size bound to cached_constrained_term_order and
%%% cached_constrained_term_order_complete
%%% cached constrained subterm rewrites
%%% added cache_size
%%%
%%% This section contains the main procedure.
%%%
%%% Prove the theorem in File.
%%% If user_control is specified, then File is the problem to be solved.
%%% Otherwise, File may be the problem itself or a file containg
%%% a list of problems depending if batch mode is used.
prove(_) :-
quintus_banner,
set_infinity_defaults,
fail.
prove(File) :-
user_control, !,
prove_1(File), !, fail.
prove(File) :-
xvisor(File), !, fail.
%%% prove_1 fails in the following cases:
%%% Read erroneous commands in interp.
%%% No user support clauses if user support strategy is specified
%%% in interp.
%%%
%%% Clear the database to avoid the interference of the assertions from
%%% the previous run.
%%% Call interpreter to assert clauses with internal format.
%%% If automatic control, check if the input is a horn set.
%%% Try to solve the given problem.
%%% Print out statistics for the tried problem.
%%% Reset flags due to horn set.
%%% If user_control, reset options that are set in the spec. of the problem.
prove_1(Prob) :-
not(not(clear_database)),
assert(file_name(Prob)),
!,
interp,
not(not(set_real_time_limit)),
check_horn_set(D),
try,
not(not(summary)),
reset_by_horn_set(D),
not(not(postproc)), !.
%%% CLEAR DATABASE
%%%
%%% Clear the database so that the remanants from the previous problem won't
%%% affect the proof of the current problem.
clear_database :- % clearing the database.
abolish(cached_constrained_term_order,5),
% cached constrained term order data.
abolish(cached_constrained_term_order_complete,4),
% cached constrained term order data.
set_counter(cached_constrained_term_order_count,0),
abolish(cached_constraint_consistent,4),
% cached constraint consistency data.
set_counter(cached_constraint_consistent_count,0),
abolish(cached_term_order,5), % cached term order data.
set_counter(cached_term_order_count,0),
abolish_rewrite_caches, % cached rewrite data
abolish(cps_A,5), % data structure for spc.
abolish(cps_I,6), % data structure for spc.
abolish(cps_O,5), % data structure for spc.
abolish(cps_U,5), % data structure for spc.
abolish(cps_V,5), % data structure for spc.
abolish(current_num,2), % get_num data
abolish(sp_size,1), % small proof size.
abolish(db_erased,1), % release memory.
abolish(dont_use_rewrite_rule,1),% temporarily suspended equation
abolish(du,2), % temporary assertions in unit simp.
abolish(error,1), % error indication.
abolish(file_name,1), % file name.
abolish(in_fms,2), % release memory.
abolish(last_hypermatch_time,1),% time spent on last hyper-matching.
abolish(lit_G,4), % general literal list.
abolish(lit_S,4), % literal list from supported clauses.
abolish(lit_N_G,5), % literal list for replacements.
abolish(lit_N_V,5), % literal list for replacements.
abolish(lit_ST_G,5), % literal list for replacements.
abolish(lit_ST_V,5), % literal list for replacements.
abolish(lit_U,3), % literal list from unit clauses.
abolish(logically_erased,2), % logically erased clauses.
abolish(no_user_clauses,0), % set in interp.
abolish(nonvar_depth_weight,2), % depth weight for non-variable.
abolish(nonvar_size_weight,2), % size weight for non-variable.
abolish(nu,1), % used in duplicate deletion.
abolish(num,1), % for numbering printed stuff.
abolish(number_inclauses,1), % number of input clauses.
abolish(ou,2), % temporary assertions in unit simp.
abolish(out_model_rc,0), % clear flag for pc prover.
abolish(part_inst,4), % partial instances
abolish(pc_time,1), % record total pc prover time.
abolish(priority_bound_increment,1), % priority_bound_increment.
abolish(proof_type,1), % proof type.
abolish(prove_result,1), % record the proof result.
abolish(replace_rule_1,5), % replace rules.
abolish(replace_rule_2,5), % replace rules.
abolish(rwe,1), % the rewrite equivs.
abolish(rwo,1), % the rewrite orderings.
abolish(rwr,4), % the rewrite rules.
abolish(sent_HM,1), % temp. clauses in hyper-matching.
abolish(sent_T,1), % temp. clauses in hyper-matching.
abolish(sent_c,1), % temp. clauses.
abolish(session_no,1), % store session no.
abolish(start_time,1), % starting time of the proof.
abolish(uparg,6), % used in duplicate deletion.
abolish(updated_arguments,0), % used in duplicate deletion.
abolish(user_support,1), % user support indicator.
abolish(user_supportset,1), % user support list.
abolish(var_depth_weight,2), % depth weight for all variables.
abolish(var_size_weight,2), % size weight for all variables.
abolish(wu_bound,1), % current hyper-match workunit bound.
session_deletions, !. % deletions done before a session.
% delete assertions of the previous session.
session_deletions :-
abolish_rewrite_caches, % cached rewrite data
abolish(complete_supp,1), % support round strategy having
% unchanged assertions.
abolish(current_support,1), % recording current support strategy.
abolish(group_descr,3), % group descriptions.
abolish(num_supp,1), % Nth support strategy in support list.
abolish(oldsentC,3), % old clauses.
abolish(oldsentC1,1), % old clauses.
abolish(over_litbound,0), % indicator, too many literals.
abolish(over_numvars,0), % indicator, too many variables.
abolish(over_priohm,0), % indicator, over priority.
abolish(over_relevance,0), % indicator, over relevance.
abolish(prio_wu,3), % counter for different priorities.
abolish(round_no,1), % current round number.
abolish(round_time,2), % the time at end of each round.
abolish(total_numhm,1), % total number of hyper-matches so far.
abolish(total_wu,1). % total number of hyper-matches so far.
%%% Set real time limit.
%%% Default is no change.
set_real_time_limit :-
\+ user_control,
time_limit(X),
set_real_time_limit(X), !.
set_real_time_limit :-
time_limit(X),
set_real_time_limit(X), !.
set_real_time_limit(T) :-
time_limit_coef(F),
abolish(real_time_limit,1),
Temp is F*T,
floor(Temp,RTL),
assert(real_time_limit(RTL)).
set_real_time_limit(T) :-
abolish(real_time_limit,1),
assert(real_time_limit(T)).
%%% If user_control, then no effect.
%%% If the input is Horn-set, then set delete_all_instances.
check_horn_set(1) :-
user_control, !.
check_horn_set(X) :-
check_horn_set_2(X),
check_horn_set_1.
check_horn_set_1 :-
sent_C(cl(_,_,by(Cn1,_,_,_,_),_,_,_,_,_,_)),
check_horn_clause(Cn1), !. % succeed if not horn set.
check_horn_set_1 :- % If horn set.
set(delete_all_instances).
check_horn_clause(Cn1) :- % fail if horn clause.
horn_clause(Cn1),
!,
fail.
check_horn_clause(_). % If not horn set.
%%% If delete_all_instances is set initially, return 1, otherwise 0.
check_horn_set_2(1) :-
delete_all_instances, !.
check_horn_set_2(0).
%%% Reset the delete_all instances if necessary.
%%% If delete_all_instances is not set initially, delete it.
reset_by_horn_set(0) :-
clear(delete_all_instances), !.
reset_by_horn_set(_).
%%%
%%% REPORT OUT
%%%
%%% Report the summary of the proof.
summary :-
cputime(T),
nl,
write_line(5,'SUMMARY:'),
report_file,
settings,
check_print_pc_model_rc,
report_proof(T), !.
%%% Print out filename and number of input clauses of the underlying problem.
report_file :-
file_name(File),
write_line(5,'Underlying-File: ',File),
number_inclauses(IN),
write_line(5,'Number-Of-Input-Clauses: ',IN).
%%% Print out options set for the underlying problem.
settings :-
member(X,[
outCacg,
outCagen,
outCahl,
outCainst,
outCasimp,
outcsplit,
outfls,
outhl,
outhllits,
outpc,
outpcin,
outrwr,
outrwt,
outtreq,
cache_size(_),
clause_splitting(_),
depth_coef(_),
literal_coef(_),
max_no_clauses(_),
relevance_bound(_),
relevance_coef(_),
size_coef(_),
start_no_clauses(_),
start_no_clauses_coef(_),
support_list(_),
term_ordering(_),
time_limit(_),
time_limit_coef(_),
time_limit_multiple(_),
back_literalbound(_),
small_proof_nucleus_bound(_),
small_proof_size_bound(_),
for_literalbound(_),
literal_bound(_),
user_literalbound(_),
start_priority_bound(_),
priority_bound_increment(_),
start_wu_bound(_),
restricted_equality_transform(_),
auto_orient,
clause_generation_loop,
constrained_rewriting,
count_all_literals,
delete_all_instances,
delete_nf_instances,
do_hyper_linking,
duplicate_partial_instance_test,
early_tautology_test,
early_unit_subsumption,
equality_early_unit_subsumption,
equality_transform,
equality_transform_by_round,
equational_rewrite,
fast_priority_update,
fixed_priority,
ground_disting_after_match,
ground_restriction,
ground_substitution,
group_detection,
hl_literal_reordering,
include_original_clause,
precompute_constraints,
pullout_constants,
realfls,
replace_literal_reordering,
replacement,
restricted_rewrite,
safe_early_priority_test,
save_unrestricted_normal_form,
save_rewrite_rules,
simple_small_proof_check,
size_by_clause,
slidepriority,
small_proof_check,
small_proof_check_all,
spc_literal_reordering,
sum_of_measures,
super_batch,
tautology_deletion,
unit_resolution,
user_control
]),
call(X),
write_line(15,'',X),
fail.
settings.
%%% Print out information about the try of the underlying problem.
report_proof(T) :-
report_trystatus,
report_proof_type,
report_session_round_no,
report_number_C_space,
report_PrWu_bounds,
report_pc_time,
report_total_time(T).
%%% What is the status of the try.
report_trystatus :-
tab(25),write('What: '),
prove_result(PR),
write(PR),nl,!.
%%% If the underlying problem was proved, how it was proved.
%%% If was proved by small proof checker, print out small proof size.
report_proof_type :-
report_proof_type_1(PT),
report_proof_type_2(PT).
report_proof_type_1(PT) :-
proof_type(PT),
write_line(25,'Proof-Type: ',PT), !.
report_proof_type_1(_).
report_proof_type_2(PT) :-
PT == 'SP',
sp_size(N1),
write_line(25,'Small_Proof_Size: ',N1), !.
report_proof_type_2(_).
%%% Print out how many rounds in the final session.
report_session_round_no :-
session_no(SessionNo),
round_no(RoundNo),
write_line(25,'Number-Of-Sessions: ',SessionNo),
write_line(25,'Number-Of-Rounds: ',RoundNo).
%%% Print out how many hyper-matches at the end.
report_number_C_space :-
get_C_number_space(0,0,M,S),
write_line(25,'Number-Of-Clauses-Retained: ',M),
write_line(25,'Space-Used-In-Units: ',S).
get_C_number_space(M1,S1,M2,S2) :-
retract(sent_C(cl(Z,_,_,_,_,_,_,_,_))),
MM is M1 + 1,
SS is S1 + Z,
!, get_C_number_space(MM,SS,M2,S2).
get_C_number_space(M,S,M,S).
%%% Print out information about sliding priority.
report_PrWu_bounds :-
slidepriority,
report_PrWu_bounds_1, !.
report_PrWu_bounds.
report_PrWu_bounds_1 :-
priority_bound(PrioBound),
write_line(25,'Priority-Bound: ',PrioBound),
wu_bound(WUBound),
write_line(25,'Work-Unit-Bound: ',WUBound), !.
report_PrWu_bounds_1.
%%% Print out total PC time used.
report_pc_time :-
tab(25),write('PC-Prover-Time: '),
report_pc_time_1.
report_pc_time_1 :-
pc_time(PCTIME), write(PCTIME), nl, !.
report_pc_time_1 :-
write(0), nl.
%%% Print out total CPU time used.
report_total_time(T) :-
start_time(Start_Time),
Used_Time is T - Start_Time,
write_line(25,'Total-Time: ',Used_Time).
%%% Print out model or relevant clauses to the proof by PC prover.
check_print_pc_model_rc :-
outpc,
print_pc_model_rc.
check_print_pc_model_rc.
print_pc_model_rc :-
prove_result('satisfiable'),
print_pc_model_rc_1, !.
print_pc_model_rc :-
proof_type('PC'),
print_pc_model_rc_1, !.
print_pc_model_rc.
print_pc_model_rc_1 :-
compute_fms(FMS),
assert(out_model_rc),
run_pc_mr(FMS),
abolish(out_model_rc,0), !.
run_pc_mr(FMS) :-
outpcin,
write_line(5,'Input to PC:'),
print_clause_list(FMS),
intell_pc(FMS,_).
run_pc_mr(FMS) :-
intell_pc(FMS,_).
%%% Postprocess commands in input file.
postproc :-
user_control,
file_name(File),
seeing(Input),
see(File),
read_till_end_input,
postproc_1,
seen,
see(Input), !.
postproc.
%%% Read input until the command following end_of_input.
read_till_end_input :-
repeat,
read(Term),
Term == 'end_of_input'.
postproc_1 :-
read(Term),
Term \== 'end_of_file',
postproc_1(Term), !,
postproc_1.
postproc_1.
%%% Perform actions according to the command.
postproc_1(set(X)) :-
set(X).
postproc_1(clear(X)) :-
clear(X).
postproc_1(assign(X,V)) :-
assign_cmd(X,V).
postproc_1(delete(X,V)) :-
delete(X,V).
postproc_1(Term) :-
write_line(5,'ERROR: Wrong input -> ',Term), !, fail.